<?php
session_start();
header ('Content-Type: text/html; charset=utf-8');
header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); // ist mal wieder wichtig wegen IE

clearstatcache();
include 'dbConn.php';
if($_GET['q'] !=""){
	$sql = "SELECT * FROM std_MitarbeiterZuGruppe mzg WHERE mzg.id_mitarbeiter='".$_SESSION['userid']."' AND mzg.id_gruppe=".$_GET['q']."";
	$db_cat_result = mysql_query($sql) or die(mysql_error());
	$cat = mysql_fetch_assoc($db_cat_result);
	
	echo $cat['id'].", ".$_SESSION['monat'].", ".$_SESSION['jahr'];
	
	$jahr = $_SESSION['jahr'];
	$monat = $_SESSION['monat'];
	
	$sql = "SELECT *, SUBTIME(SUBTIME(Ende,Begin),Abwesend) AS Stunden FROM std_Arbeitszeit"
			." WHERE MitarbeiterId = '".$cat['id']."'"
			." AND MONTH(Arbeitstag) = '$monat'"
			." AND YEAR(Arbeitstag) = '$jahr'"
			." ORDER BY Arbeitstag";

	$result = mysql_query($sql) or die (mysql_error());
	echo("<div class='showScreen'><br/></div>");
		echo ("<table style='table-layout:fixed;' rules='cols' border='0'>\n");
		echo ("<form action='".$_SERVER['SCRIPT_NAME']."' method='post'>\n");
		echo ("<tr>");
		echo("<th>Tag</th>");
		echo("<th colspan='1'>Beginn</th>");
		echo("<th colspan='1'>Ende</th>");
		echo("<th colspan='1'>Abwesend</th>");
		echo("<th colspan='1'>Stunden</th>");
		echo("<th>Bemerkung</th>");
		echo("</tr>\n");
		$first = date("Y-m-d", mktime(0, 0, 0, intval($monat), 1, intval($jahr)));
		$even = 0;
		echo mysql_num_rows($result);
		while ($tag = mysql_fetch_assoc($result)){
			echo $tag->Begin;
			//nicht gearbeitete tage#

		}
		echo ("</form>\n");
		echo ("</table>\n");
	echo("</div>");
		mysql_free_result($result);
	
}
else{
		echo("Bitte w&auml;hlen Sie einen Dozenten...");
	}
mysql_close($db_connect);
?>